/****************************************************************************
 * Copyright 2009 Huascar A. Sanchez                                        *
 *                                                                          *
 * Licensed under the Apache License, Version 2.0 (the "License");          *
 * you may not use this file except in compliance with the License.         *
 * You may obtain a copy of the License at                                  *
 *                                                                          *
 *     http://www.apache.org/licenses/LICENSE-2.0                           *
 *                                                                          *
 * Unless required by applicable law or agreed to in writing, software      *
 * distributed under the License is distributed on an "AS IS" BASIS,        *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
 * See the License for the specific language governing permissions and      *
 * limitations under the License.                                           *
 ****************************************************************************/
package com.gotobject.filter;

import static com.gotobject.filter.FilterQ.from;
import static com.gotobject.filter.common.Predicates.mod;
import static com.gotobject.filter.common.Iterables.asList;
import com.gotobject.junit.ConfigureWith;
import com.gotobject.junit.Load;
import com.gotobject.junit.runner.Launcher;
import com.gotobject.junit.runners.ConditionalJUnitPerfClassRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Arrays;
import java.util.List;

/**
 * @author huascar.sanchez@gmail.com (Huascar A. Sanchez)
 */
@RunWith(ConditionalJUnitPerfClassRunner.class)
public class StressFrameworkTest {
    private final List<Integer> data = Arrays.asList(
            1, 2, 3, 4, 5, 6, 7, 8, 9,
            10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
            30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
            40, 41, 42, 43, 44, 45, 46, 37, 38, 39,
            50
    );
    public static void main(String[] args) {
        Launcher.of(StressFrameworkTest.class);
    }

    @Load("performanceData")
    @Test
    public void filteringACollectionUsing_HundredUsers_ThousandIterations(){
        final Iterable<Integer> result = from(data).select(mod(3));
        for(Integer each : result){
            Assert.assertSame("element is multiple of 3", 0, (each % 3));
        }
        Assert.assertSame("same number of elements", 16, asList(result).size());
    }

    @Test
    public void filteringACollectionUsing_HundredUsers_ThousandIterations_Response() throws Exception {
        // todo
    }

    @ConfigureWith
    public static Object[][] performanceData(){
        return new Object[][]{
                new Object[]{1, 1}
        };
    }
}
